package com.sec.android.app.myfiles.activity;

import android.content.res.Configuration;
import android.os.Bundle;
import android.view.MenuItem;

import com.sec.android.app.myfiles.R;
import com.sec.android.app.myfiles.log.SamsungAnalyticsLog;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.navigation.NavigationInfo;
import com.sec.android.app.myfiles.util.UiUtils;

/**
 * Created by daesu83.kim on 2017-01-19.
 */

public class GetMoreSpaceActivity extends FileListActivity {

    public static final String EXTRA_KEY_GET_MORE_SPACE = "get_more_space";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getIntent().putExtra(EXTRA_KEY_GET_MORE_SPACE, true);
        super.onCreate(savedInstanceState);
        UiUtils.setContentsArea(this, R.id.right_contents_container, getResources().getConfiguration().screenWidthDp);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                SamsungAnalyticsLog.sendLog(getProcessId(), SamsungAnalyticsLog.Event.NAVIGATE_UP, null);
                finish();
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        NavigationInfo curInfo = mNavigationManager.getCurInfo();
        if (curInfo != null && curInfo.getStorageType() == FileRecord.StorageType.OptimizeStorage) {
            UiUtils.setContentsArea(this, R.id.right_contents_container, newConfig.screenWidthDp);
        }
    }

    @Override
    public void onNavigationChanged(NavigationInfo preInfo, NavigationInfo curInfo) {
        super.onNavigationChanged(preInfo, curInfo);
        if (curInfo != null && curInfo.getStorageType() != FileRecord.StorageType.OptimizeStorage) {
            UiUtils.setContentsArea(this, R.id.right_contents_container, curInfo.isLeftPanelDisabled());
        }
    }
}
